import 'package:flutter/material.dart';
import 'package:ui_templates/drawer_row/drawer_row.dart';
import 'package:ui_templates/drawer_row/home_drawer.dart';
import 'package:ui_templates/feedback_page.dart';
import 'package:ui_templates/help_page.dart';
import 'package:ui_templates/home_page.dart';
import 'package:ui_templates/invite_friends_page.dart';

class NavigationHome extends StatefulWidget {
  const NavigationHome({super.key});

  @override
  State<NavigationHome> createState() => _NavigationHomeState();
}

class _NavigationHomeState extends State<NavigationHome> {
  DrawerIndex currentIndex = DrawerIndex.HOME;
  Widget currentPage = HomePage();

  Widget changePage(DrawerIndex index) {
    switch (index) {
      case DrawerIndex.FeedBack:
        currentPage = const FeedBackPage();
        break;
      case DrawerIndex.Help:
        currentPage = const HelpPage();
        break;
      case DrawerIndex.HOME:
        currentPage = HomePage();
        break;
      case DrawerIndex.Invite:
        currentPage = const InviteFriendsPage();
        break;
      default:
        currentPage = const InviteFriendsPage();
        break;
    }
    return currentPage;
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      top: false,
      child: DrawerRow(
        drawerWidth: MediaQuery.of(context).size.width * 0.75,
        onIndexTap: (DrawerIndex selected) {
          print("navigation $selected ");
          setState(() {
            currentIndex = selected;
          });
        },
        currentPage: changePage(currentIndex),
        currentIndex: currentIndex,
      ),
    );
  }
}
